home *** CD-ROM | disk | FTP | other *** search
/ IRIX 6.5 Applications 2002 November / SGI IRIX 6.5 Applications 2002 November.iso / dist / gateway.idb / usr / WebFace / Source / 20-NetworkServices / nfs / nfs-mount.frm.z / nfs-mount.frm
Encoding:
Text File  |  2002-06-12  |  23.2 KB  |  749 lines

  1. #!/usr/bin/perl5
  2.  
  3. # nfs-mount.cgi
  4.  
  5. # notes: \ at end of line to continue not supported.
  6. # (this is supported for nfs-export)
  7.  
  8. require "/usr/OnRamp/lib/OnRamp.pm";
  9. require "/usr/OnRamp/lib/java.pm";
  10.  
  11. $myname = "nfs-mount.cgi";
  12. $help_page = "nfs-mount-help.html";
  13. $title = "Filesystem Configuration";
  14. $conf = "/etc/fstab";
  15. $temp = "/etc/fstab.tmp";
  16.  
  17. $account_type_uc = "Filesystem";
  18. $account_type_lc = "filesystem";
  19.  
  20. $js_main =
  21. "type = \"filesystem\";
  22. $js_account_main
  23. $js_help
  24. $js_error_box
  25. $js_filename
  26. $js_hostname
  27. function testFilesystem(form, Ctrl, what) {
  28.     colon = Ctrl.value.indexOf(':', 0);
  29.     if (colon < 0) {
  30.         if (!testFilename(Ctrl, what)) return (false);
  31.     } else {
  32.         host = Ctrl.value.substring(0, colon);
  33.         file = Ctrl.value.substring(colon + 1);
  34.         if (!testHostname(Ctrl, host, what, 0)) return (false);
  35.         if (!testThisFilename(form.edit, file, what)) return (false);
  36.     }
  37.     return (true);
  38. }
  39. function testThisFilename(Ctrl, word, what) {
  40.         if (word == \"\") {
  41.                 errorBox (Ctrl, \"The \" + what + \" is required.\");
  42.                 return (false);
  43.         }
  44.         if (!testFileChars(word)) {
  45.                 errorBox (Ctrl, \"The \" + what + \" cannot \\ncontain \"
  46.                         + illegal + \" characters.\");
  47.                 return (false);
  48.         }
  49.         for(i = 0; i < word.length; i++) {
  50.                 if (word.charAt(i) == ' ') {
  51.                         errorBox (Ctrl, \"The \" + what + \" cannot \\ncontain spaces.\");
  52.                         return (false);
  53.                 }
  54.         }
  55.         if (word.charAt(0) != '/') {
  56.                 errorBox (Ctrl, \"The \" + what + \" must be fully qualified.\");
  57.                 return (false);
  58.         }
  59.         return (true);
  60. }
  61. function testFileChars(word) {
  62.         metaChars = \"{}()*!~<>?|[]'&^\$\@\#`\\\";:\";
  63.         for(j = 0; j < metaChars.length; j++) {
  64.                 illegal = metaChars.charAt(j);
  65.                 if (word.indexOf (illegal, 0) != -1) return (false);
  66.         } return (true);
  67. }
  68. function testAdd(form) {
  69.     if (form.new_account.value == \"\") {
  70.         errorBox (form.new_account, \"To add an existing \" + type + \", \"
  71.             + \"first enter a \" + type + \"\\n\"
  72.             + \"then click the add button.\");
  73.         return (false);
  74.     }
  75.     if (!testFilesystem(form, form.new_account, \"filesystem\")) return (false);
  76.     return (true);
  77. }";
  78.  
  79. $js_edit =
  80. "$js_standard
  81. $js_help
  82. $js_error_box
  83. $js_filename
  84. function checkForm(form)  {
  85.     if (!testFilename(form.dir, \"mount directory\")) return (false);
  86.     return (true);
  87. }";
  88.  
  89. $js_options =
  90. "$js_check_int
  91. $js_help
  92. $js_standard
  93. $js_error_box
  94. $js_filename
  95. function testNumber(Ctrl, what) {
  96.     if (Ctrl.value == \"\") return (true);
  97.     if (! checkInt(Ctrl.value, 10)) {
  98.         errorBox(Ctrl, \"The \" + what + \" entered is not a number.\");
  99.         return (false);
  100.     }
  101.     return (true);
  102. }
  103. function testVersion(Ctrl, what) {
  104.     if (Ctrl.value == \"\") return (true);
  105.     if (Ctrl.value != \"2\" && Ctrl.value != \"3\") {
  106.         errorBox(Ctrl, \"The \" + what + \" must be 2 or 3.\");
  107.         return (false);
  108.     }
  109.     return (true);
  110. }
  111. function testPortNo(Ctrl, what) {
  112.     if (Ctrl.value == \"\") return (true);
  113.     num = parseInt(Ctrl.value);
  114.     if ((! checkInt(Ctrl.value, 10)) || num < 0 || num > 65536) {
  115.         errorBox(Ctrl, \"The \" + what + \" must be a number between 0 and 65,535\");
  116.         return (false);
  117.     }
  118.     return (true);
  119. }
  120. function testPriority(Ctrl, what) {
  121.     if (Ctrl.value == \"\") return (true);
  122.     num = parseInt(Ctrl.value);
  123.     if ((! checkInt(Ctrl.value, 10)) || num < 0 || num > 7) {
  124.         errorBox(Ctrl, \"The \" + what + \" must be a number between 0 and 7\");
  125.         return (false);
  126.     }
  127.     return (true);
  128. }
  129. function testFile(Ctrl, what) {
  130.     if (Ctrl.value == \"\") return (true);
  131.     if (!testFilename(Ctrl, what)) return (false);
  132.     return (true);
  133. }
  134. function checkForm(form)  {
  135.     type = form.type.value;
  136.     if (type != \"swap\" && type != \"cachefs\") {
  137.         if (!testFile(form.raw, \"raw device pathname\")) return (false);
  138.         if (!testNumber(form.lbsize, \"transfer bytes\")) return (false);
  139.     }
  140.     if (type == \"iso9660\") {
  141.         if (!testNumber(form.cache, \"caching blocks\")) return (false);
  142.     }
  143.     if (type == \"dos\") {
  144.         if (!testNumber(form.partition, \"DOS partition\")) return (false);
  145.     }
  146.     if (type == \"nfs\") {
  147.         if (!testVersion(form.vers, \"NFS version\")) return (false);
  148.         if (!testNumber(form.retry, \"mount retry times\")) return (false);
  149.         if (!testNumber(form.rsize, \"read buffer size\")) return (false);
  150.         if (!testNumber(form.wsize, \"write buffer size\")) return (false);
  151.         if (!testNumber(form.timeo, \"NFS timeout\")) return (false);
  152.         if (!testNumber(form.retrans, \"NFS retransmissions\")) return (false);
  153.         if (!testPortNo(form.port, \"UDP port number\")) return (false);
  154.         if (!testNumber(form.symttl, \"time-to-live\")) return (false);
  155.     }
  156.     if (type == \"nfs\" || type == \"cachefs\") {
  157.         if (!testNumber(form.acregmin, \"cache timeout\")) return (false);
  158.         if (!testNumber(form.acregmax, \"cache timeout\")) return (false);
  159.         if (!testNumber(form.acdirmin, \"cache timeout\")) return (false);
  160.         if (!testNumber(form.acdirmax, \"cache timeout\")) return (false);
  161.         if (!testNumber(form.actimeo, \"cache timeout\")) return (false);
  162.     }
  163.     if (type == \"swap\") {
  164.         if (!testPriority(form.pri, \"priority\")) return (false);
  165.         if (!testNumber(form.swplo, \"starting block\")) return (false);
  166.         if (!testNumber(form.slength, \"swap size\")) return (false);
  167.         if (!testNumber(form.maxlength, \"maximum swap size\")) return (false);
  168.         if (!testNumber(form.vlength, \"virtual length\")) return (false);
  169.     }
  170.     if (type == \"cachefs\") {
  171.         if (!testFile(form.backpath, \"mount point\")) return (false);
  172.         if (!testFile(form.cachedir, \"cache directory\")) return (false);
  173.     }
  174.     
  175.     return (true);
  176. }";
  177.  
  178.  
  179. print "Content-type: text/html\n\n";
  180.  
  181. &get_fields;
  182.  
  183. &getAccounts;
  184.  
  185. if (%fld) {
  186.     $fld{'chosen'} =~ /([\w.-\/:]+)/;
  187.     $name = $1;
  188.  
  189.     $help = $document_root . $ENV{"SCRIPT_NAME"};
  190.     $help =~ s/cgi$/hlp/;
  191.     exec $help if ($fld{'help'} eq "Help");
  192.  
  193.     if ($fld{'options'} eq "Options") {
  194.         &make_options;
  195.     }
  196.     if ($fld{'add'}) {
  197.         $name = $fld{'new_account'};
  198.         $ttl = "Add Filesystem";
  199.         &editAccount;
  200.     }
  201.     if ($fld{'edit'} || $fld{'get_options'}) { 
  202.         if ($fld{'edit'}) { &get_vals($name); }
  203.         else {
  204.             $val{'dir'} = $fld{'dir'};
  205.             $val{'type'} = $fld{'type'};
  206.             $name = $fld{'chosen'};
  207.  
  208.             $val{'opt_string'} = &create_opt_string;
  209.  
  210.             $message .= "Click \"Ok\" to save changes.";
  211.         }
  212.         $ttl = "Edit Filesystem";
  213.         &editAccount; 
  214.         exit 0;
  215.     }
  216.     if ($fld{'ok'}) { 
  217.         &doEdit; 
  218.         &getAccounts; 
  219.         &generic; 
  220.     }
  221.     if ($fld{'delete'}) {
  222.         $message = qq|Click "Ok" to save changes.|;
  223.         $delete = 1;
  224.         &generic;
  225.     }
  226.     if ($fld{'doit'}) {
  227.         if ($fld{'delFile'}) { 
  228.             &delete($fld{'delFile'}); 
  229.             &getAccounts;
  230.         }
  231.         &generic;
  232.     }
  233. } else { &generic; }
  234.  
  235. sub delete {
  236.     open(IN, "< $conf");
  237.     open(OUT, "> $temp");
  238.     while(<IN>) {
  239.         @items = split(/\s+/);
  240.         if ($items[0] ne $_[0]) { print OUT $_; }
  241.     }
  242.     close(IN);
  243.     close(OUT);
  244.  
  245.     rename($temp, $conf);
  246.  
  247.     $message .= "Entry deleted.";
  248. }
  249.  
  250. sub doEdit {
  251.     $new_line = "$fld{'chosen'} $fld{'dir'} $fld{'type'} $fld{'opt_string'} 0 0";
  252.  
  253.     if ($fld{'mode'} eq "add") {
  254.         open(OUT, ">> $conf");
  255.         print OUT "$new_line\n";
  256.         close(OUT);
  257.  
  258.         $message .= "Entry added.";
  259.     } else {
  260.         open(IN, "< $conf");
  261.         open(OUT, "> $temp");
  262.         while(<IN>) {
  263.             @items = split(/\s+/);
  264.             if ($items[0] eq $fld{'chosen'}) { 
  265.                 print OUT "$new_line\n";
  266.             } else { print OUT $_; }
  267.         }
  268.         close(IN);
  269.         close(OUT);
  270.  
  271.         rename($temp, $conf);
  272.  
  273.         $message .= "Entry edited.";
  274.     }
  275. }
  276.  
  277. sub get_vals {
  278.     for($i=0; $i<=$#accounts; $i++) {
  279.         if ($accounts[$i] eq $_[0]) {
  280.             $val{'dir'} = $dir[$i];
  281.             $val{'type'} = $type[$i];
  282.             $val{'opt_string'} = $opt_string[$i];
  283.         }
  284.     }
  285. }    
  286.  
  287. sub create_opt_string {
  288.     &get_options;
  289.     &get_defs;
  290.  
  291.     undef (@opts);
  292.     
  293.     if ($fld{'ro'} eq "No") { push(@opts, "rw"); }
  294.  
  295.     if ($fld{'type'} ne 'swap' && $fld{'type'} ne 'cachefs') { &add_opts(*st_opt); }
  296.  
  297.     if ($fld{'type'} eq 'xfs') { &add_opts(*xfs_opt); }
  298.     elsif ($fld{'type'} eq 'efs') { &add_opts(*efs_opt); }
  299.     elsif ($fld{'type'} eq 'iso9660') { &add_opts(*iso_opt); }
  300.     elsif ($fld{'type'} eq 'dos') { &add_opts(*dos_opt); }
  301.     elsif ($fld{'type'} eq 'nfs') { &add_opts(*nfs_opt); }
  302.     elsif ($fld{'type'} eq 'cachefs') { &add_opts(*cache_opt); }
  303.     elsif ($fld{'type'} eq 'swap') { &add_opts(*swap_opt); }
  304.  
  305.     return join(',', @opts);
  306. }
  307.  
  308. sub add_opts {
  309.     local(*lst) = $_[0];
  310.  
  311.     for ($i=0; $i<$#lst; $i+=3) {
  312.         next if $fld{$lst[$i]} eq $def{$lst[$i]};
  313.         if ($lst[$i+1] eq 'r') { push(@opts, $lst[$i]); }
  314.         elsif ($lst[$i] eq "slength") { push(@opts, "length=$fld{$lst[$i]}"); }
  315.         elsif ($lst[$i+1] eq 't') { 
  316.             push(@opts, "$lst[$i]=$fld{$lst[$i]}") if $fld{$lst[$i]}; 
  317.         } else {
  318.             if ($lst[$i] eq 'nmconv') {
  319.                 undef ($ch);
  320.                 $ch = "c" if $fld{'nmconv'} eq "Don't translate to UNIX";
  321.                 $ch = "l" if $fld{'nmconv'} eq "Translate to lower case";
  322.                 $ch = "m" if $fld{'nmconv'} eq "Suppress version number";
  323.             
  324.                 if ($ch) { push(@opts, "nmconv=$ch"); }
  325.             } elsif ($lst[$i] eq 'backfstype') {
  326.                 push(@opts, "$lst[$i]=$fld{$lst[$i]}");
  327.             } elsif ($lst[$i] eq 'write-around') {
  328.                 push(@opts, "write-around");
  329.             }
  330.         }
  331.     }
  332. }
  333.  
  334. sub get_defs {
  335.     for ($i=0; $i<$#st_opt; $i+=3) { 
  336.         if ($st_opt[$i+1] eq 'r') { $def{$st_opt[$i]} = "No"; }
  337.     }
  338.     for ($i=0; $i<$#xfs_opt; $i+=3) {
  339.         if ($xfs_opt[$i+1] eq 'r') { $def{$xfs_opt[$i]} = "No"; }
  340.     }
  341.     for ($i=0; $i<$#efs_opt; $i+=3) {
  342.         if ($efs_opt[$i+1] eq 'r') { $def{$efs_opt[$i]} = "No"; }
  343.     }
  344.     for ($i=0; $i<$#iso_opt; $i+=3) {
  345.         if ($iso_opt[$i+1] eq 'r') { $def{$iso_opt[$i]} = "No"; }
  346.     }
  347.     for ($i=0; $i<$#nfs_opt; $i+=3) {
  348.         if ($nfs_opt[$i+1] eq 'r') { $def{$nfs_opt[$i]} = "No"; }
  349.     }
  350.     for ($i=0; $i<$#cache_opt; $i+=3) {
  351.         if ($cache_opt[$i+1] eq 'r') { $def{$cache_opt[$i]} = "No"; }
  352.     }
  353.     for ($i=0; $i<$#swap_opt; $i+=3) {
  354.         if ($swap_opt[$i+1] eq 'r') { $def{$swap_opt[$i]} = "No"; }
  355.     }
  356.  
  357.     $def{'partition'} = 1;
  358.     $def{'cache'} = 128;
  359.     $def{'retry'} = 10000;
  360.     $def{'rsize'} = 8096;
  361.     $def{'wsize'} = 8096;
  362.     $def{'timeo'} = 11;
  363.     $def{'retrans'} = 5;
  364.     $def{'port'} = 2049;
  365.     $def{'hard'} = "Yes";
  366.     $def{'acregmin'} = 3;
  367.     $def{'acregmax'} = 60;
  368.     $def{'acdirmin'} = 30;
  369.     $def{'acdirmax'} = 60;
  370.     $def{'symttl'} = 3600;    
  371.     $def{'swplo'} = 0;
  372.  
  373.     if ($fld{'type'} eq "cachefs") {
  374.         $def{'actimeo'} = 30;
  375.     }
  376.  
  377.     $def{'nmconv'} = "None";
  378.     $def{'backfstype'} = "default";
  379.     $def{'write-around'} = "non-shared";
  380.     
  381.  
  382. }
  383.  
  384. sub get_options {
  385.     @st_opt =         (    
  386.         'ro',         'r',    'Mount read-only?',
  387.     'noauto',     'r',    'Ignore during "mount -a" command?',
  388.     'grpid',     'r',    'Set group id to group id of parent directory?',
  389.     'nosuid',    'r',    'Setuid execution not allowed for non-superusers?',
  390.     'nodev',    'r',    'Deny access to character and block special files?',
  391.     );
  392.  
  393.     @xfs_opt =         (
  394.         'quota',    'r',    'Enforce disk quotas?',
  395.         'dmi',        'r',    'Enable the Data Management Interface event callouts?',
  396.         'qnoenforce',    'r',    'Enable disk quotas, but don\'t enforce limits?',
  397.     );
  398.  
  399.     @efs_opt =         (
  400.         'raw',        't',    'Raw device pathname:',
  401.         'nofsck',    'r',    'Have "fsck" not check this filesystem by default?',
  402.         'noquota',    'r',    'Enforce disk quotas?',
  403.         'lbsize',    't',    'Number of bytes to transfer in each read or synchronous '
  404.                             . 'write operation:'
  405.     );
  406.  
  407.     @iso_opt =        (    
  408.         'setx',        'r',    'Set execute permission on all files?',
  409.         'notranslate',    'r',    'Don\'t translate ISO 9660 filenames to UNIX filenames?',
  410.         'cache',    't',    'Number of 2048 byte blocks used for caching:',
  411.         'noext',    'r',    'Ignore Rock Ridge extensions?',
  412.         'nosusp',    'r',    'Disable processing of System Use Sharing Protocol?',
  413.         'nmconv',    's',    'Filename translation control:',
  414.     );
  415.  
  416.     @dos_opt =        (    
  417.         'partition',    't',    'Mount which DOS partition:'
  418.     );
  419.  
  420.     @nfs_opt =        (    
  421.         'quota',    'r',    'Enforce disk quotas?',
  422.         'vers',        't',    'NFS protocol version:',
  423.         'bg',        'r',    'If the first mount attempt fails, retry in the background?',
  424.          'retry',    't',    'Number of times to retry mount in case of failure:',
  425.          'rsize',    't',    'Read buffer size:',
  426.          'wsize',    't',    'Write buffer size:',
  427.          'timeo',    't',    'NFS timeout in tenths of seconds:',
  428.          'retrans',    't',    'NFS retransmissions:',
  429.          'port',    't',    'Server UDP port number:',
  430.          'soft',    'r',    'Return error if server doesn\'t respond?',
  431.          'nointr',    'r',    'Disallow signal interrupts of accesses?',
  432.          'acregmin',    't',    'Cache timeout of regular file minimum attribute in seconds:',
  433.          'acregmax',    't',    'Cache timeout of regular file maximum attribute in seconds:',
  434.          'acdirmin',    't',    'Cache timeout of directory minimum attribute in seconds:',
  435.          'acdirmax',    't',    'Cache timeout of directory maximum attribute in seconds:',
  436.          'actimeo',    't',    'Cache timeout of regular and directory minimum and maximum '
  437.                 . 'attribute in seconds:',
  438.          'noac',    'r',    'No attribute caching?',
  439.          'private',    'r',    'Do not flush delayed writes on last close of an open file, '
  440.                 . 'and use local file and record locking instead of '
  441.                 . 'a remote lock manager?',
  442.          'shortuid',    'r',    'Do not let users with userids or groupids larger than 65535 '
  443.                 . 'create or own files?',
  444.          'symttl',    't',    'Time-to-live of symbolic links cached by NFS',
  445.          'asyncnlm',    'r',    'Use asynchronous NLM RPC calls?'
  446.      );
  447.  
  448.     @swap_opt =       ( 
  449.         'noauto',    'r',    'Ignore during "mount -a" command?',
  450.         'pri',        't',    'Priority level of swap device:',
  451.         'swplo',    't',    'Starting 512 byte block:',
  452.         'slength',    't',     'Number of 512 byte blocks to use:',
  453.         'maxlength',    't',    'Maximum number of 512 byte blocks to grow swap area to:',
  454.         'vlength',    't',    'Number of virtual 512 byte blocks to claim this swap area has:'
  455.     ); 
  456.  
  457.     @cache_opt =      ( 
  458.          'backfstype',    's',    'Filesystem type of back filesystem:',
  459.          'backpath',     't',    'Point where back filesystem is already mounted:',
  460.          'cachedir',    't',    'Name of cache directory:',
  461.          'cacheid',    't',    'Cache ID string:',
  462.          'write-around',    's',    'Write mode for cache filesystem:',
  463.          'noconst',    'r',    'Disable consistency checking?',
  464.          'private',    'r',    'Perform file and record locking locally?',
  465.          'local-access',    'r',    'Allow front filesystem to interpret the mode bits used for '
  466.                 . 'access checking?',
  467.          'purge',    'r',    'Purge cached information for filesystem?',
  468.          'nosuid',    'r',    'Disallow set-uid execution?',
  469.          'acregmin',     't',   'Minimum hold time for cached attributes:',
  470.          'acregmax',    't',    'Maximum hold time for cached attributes:', 
  471.          'acdirmin',    't',    'Minimum hold time for cached attributes after directory update:',
  472.          'acdirmax',    't',    'Maximum hold time for cached attributes after directory update:',
  473.          'actimeo',    't',    'Common value for above four caching times:',
  474.          'bg',        'r',    'Run mount in background if back filesystem mount times out?',
  475.          'disconnect',    'r',    'Operate cache filesystem in disconnected mode when the '
  476.                      . 'back filesystem fails to respond?'
  477.      );
  478. }
  479.  
  480. sub read_opts {
  481.     open(IN, "< $conf");
  482.     while(<IN>) {
  483.         @items = split(/\s+/);
  484.         if ($items[0] eq $_[0]) {
  485.             @opts = split(/,/, $items[3]);
  486.             foreach (@opts) {
  487.                 if ($_ =~ /^(.*)=(.*)$/) { 
  488.                     if ($1 eq "nmconv") { 
  489.                         $val{'nmconv'} = "Don't translate to UNIX" if $2 eq "c";
  490.                         $val{'nmconv'} = "Translate to lower case" if $2 eq "l";
  491.                         $val{'nmconv'} = "Suppress version number" if $2 eq "m";
  492.                     } else { $val{$1} = $2; }
  493.                 } else { $val{$_} = "Yes"; }
  494.             }
  495.         }
  496.     }
  497.     close(IN);
  498. }
  499.  
  500. sub make_options {
  501.     &get_options;
  502.     &get_defs;
  503.     %val = %def;
  504.     &read_opts($fld{'chosen'});
  505.  
  506.     &js_title_block($title,$js_options);
  507.     &header_block("Options for $fld{'type'}");
  508.  
  509.     print "<form name=StandardForm action=$myname method=post onSubmit=\"return runSubmit()\">";
  510.  
  511.     print "<input type=hidden name=\"get_options\" value=\"get_options\">\n";
  512.     print "<input type=hidden name=\"chosen\" value=$fld{'chosen'}>\n";
  513.     print "<input type=hidden name=\"dir\" value=$fld{'dir'}>\n";
  514.     print "<input type=hidden name=\"type\" value=$fld{'type'}>\n";
  515.     print qq|<input type=hidden name="mode" value=$fld{'mode'}>|;
  516.  
  517.     if ($fld{'type'} ne 'swap' && $fld{'type'} ne 'cachefs') {
  518.  
  519.         print "<h2>Standard Options:</h2>\n";
  520.         print "<center><table cellpadding=5 width=450>";
  521.  
  522.         for($i=0; $i<$#st_opt; $i+=3) {
  523.             print "<tr><th align=left>$st_opt[$i+2]</th><th align=left>";
  524.             if ($st_opt[$i+1] eq 'r') { print &radio($st_opt[$i], $val{$st_opt[$i]}, "Yes", "No"); }
  525.             print "</th></tr>\n";
  526.         }
  527.  
  528.         print "</table></center><br>";
  529.     }
  530.  
  531.     if ($fld{'type'} eq 'xfs') {
  532.         print "<h2>XFS Options:</h2>\n";
  533.         print "<center><table cellpadding=5 width=450>";
  534.  
  535.         for($i=0; $i<$#xfs_opt; $i+=3) {
  536.             print "<tr><th align=left>$xfs_opt[$i+2]</th><th align=left>";
  537.             if ($xfs_opt[$i+1] eq 'r') { print &radio($xfs_opt[$i], $val{$xfs_opt[$i]}, "Yes", "No"); }
  538.             print "</th></tr>\n";
  539.         }
  540.  
  541.         print "</table></center><br>";
  542.  
  543.     } elsif ($fld{'type'} eq 'efs') {
  544.         print "<h2>EFS Options:</h2>\n";
  545.         print "<center><table cellpadding=5 width=450>";
  546.  
  547.         for($i=0; $i<$#efs_opt; $i+=3) {
  548.             print "<tr><th align=left>$efs_opt[$i+2]</th><th align=left>";
  549.             if ($efs_opt[$i+1] eq 'r') { print &radio($efs_opt[$i], $val{$efs_opt[$i]}, "Yes", "No"); }
  550.             elsif ($efs_opt[$i+1] eq 't') { print &text($efs_opt[$i], $val{$efs_opt[$i]}, 20); }
  551.             print "</th></tr>\n";
  552.         }
  553.  
  554.         print "</table></center><br>";
  555.  
  556.     } elsif ($fld{'type'} eq 'iso9660') {
  557.  
  558.         print "<h2>ISO9660 Options:</h2>\n";
  559.         print "<center><table cellpadding=5 width=450>";
  560.         
  561.         for($i=0; $i<$#iso_opt; $i+=3) {
  562.             print "<tr><th align=left>$iso_opt[$i+2]</th><th align=left>";
  563.             if ($iso_opt[$i+1] eq 'r') { print &radio($iso_opt[$i], $val{$iso_opt[$i]}, "Yes", "No"); }
  564.             elsif ($iso_opt[$i+1] eq 't') { print &text($iso_opt[$i], $val{$iso_opt[$i]}, 20); }
  565.             else { print &select($iso_opt[$i], $val{$iso_opt[$i]}, "None", "Don't translate to UNIX",
  566.                         "Translate to lower case", "Suppress version number"); }
  567.             print "</th></tr>\n";
  568.         }
  569.  
  570.         print "</table></center><br>";
  571.  
  572.     } elsif ($fld{'type'} eq 'dos') {
  573.  
  574.         print "<h2>DOS Options:</h2>\n";
  575.         print "<center><table cellpadding=5 width=450>";
  576.  
  577.         print "<tr><th align=left>Mount which DOS partition:</th><th align=left>";
  578.         print &text("partition", $val{'partition'}, 20);
  579.         print "</th></tr>\n";
  580.  
  581.         print "</table></center><br>";
  582.  
  583.     } elsif ($fld{'type'} eq 'nfs') {
  584.  
  585.         print "<h2>NFS Options:</h2>\n";
  586.         print "<center><table cellpadding=5 width=450>";
  587.  
  588.         for($i=0; $i<$#nfs_opt; $i+=3) {
  589.             print "<tr><th align=left>$nfs_opt[$i+2]</th><th align=left>";
  590.             if ($nfs_opt[$i+1] eq 'r') { print &radio($nfs_opt[$i], $val{$nfs_opt[$i]}, "Yes", "No"); }
  591.             elsif ($nfs_opt[$i+1] eq 't') { print &text($nfs_opt[$i], $val{$nfs_opt[$i]}, 20); }
  592.             else { ; }
  593.             print "</th></tr>\n";
  594.         }
  595.  
  596.         print "</table></center><br>";
  597.  
  598.     } elsif ($fld{'type'} eq 'swap') {
  599.  
  600.         print "<h2>Swap Options:</h2>\n";
  601.         print "<center><table cellpadding=5 width=450>";
  602.  
  603.         for($i=0; $i<$#swap_opt; $i+=3) {
  604.             print "<tr><th align=left>$swap_opt[$i+2]</th><th align=left>";
  605.             if ($swap_opt[$i+1] eq 'r') { print &radio($swap_opt[$i], $val{$swap_opt[$i]}, "Yes", "No"); }
  606.             elsif ($swap_opt[$i+1] eq 't') { print &text($swap_opt[$i], $val{$swap_opt[$i]}, 20); }
  607.             else { ; }
  608.             print "</th></tr>\n";
  609.         }
  610.  
  611.         print "</table></center><br>";
  612.  
  613.     } elsif ($fld{'type'} eq 'cachefs') {
  614.  
  615.         print "<h2>Cachefs Options:</h2>\n";
  616.         print "<center><table cellpadding=5 width=450>";
  617.  
  618.         for($i=0; $i<$#cache_opt; $i+=3) {
  619.             print "<tr><th align=left>$cache_opt[$i+2]</th><th align=left>";
  620.             if ($cache_opt[$i+1] eq 'r') { print &radio($cache_opt[$i], 
  621.                             $val{$cache_opt[$i]}, "Yes", "No"); }
  622.             elsif ($cache_opt[$i+1] eq 't') { print &text($cache_opt[$i], $val{$cache_opt[$i]}, 20); }
  623.             elsif ($cache_opt[$i] eq "backfstype") {
  624.                 print &select($cache_opt[$i], $val{$cache_opt[$i]}, "default", "nfs", "nfs3",
  625.                         "iso9660", "dos", "cdfs", "kfs", "hfs");
  626.             } else {
  627.                 print &select($cache_opt[$i], $val{$cache_opt[$i]}, 
  628.                         "write-arount", "non-shared");
  629.             }
  630.             print "</th></tr>\n";
  631.         }
  632.  
  633.         print "</table></center><br>";
  634.     }
  635.  
  636.     print &js_buttons('ok','Ok','onClick="markOK()"',
  637.         'onClick="markOther()"',
  638.         "onClick=\"do_help('$help_page'); return (false)\"");
  639.  
  640.     print "</form></body></html>";
  641. }
  642.     
  643.  
  644. sub editAccount {
  645.     &js_title_block($title,$js_edit);
  646.     &header_block($ttl);
  647.  
  648.     print "<i>$message</i>\n";
  649.  
  650.     print "<form name=StandardForm action=$myname method=post onSubmit=\"return runSubmit()\">";
  651.  
  652.     print qq|<input type=hidden name="chosen" value=$name>|;
  653.     if ($fld{'add'}) { $mode = "add"; } else { $mode = "edit"; }
  654.     $mode = $fld{'mode'} if $fld{'mode'};
  655.     print qq|<input type=hidden name="mode" value=$mode>|;
  656.     print qq|<input type=hidden name="opt_string" value=$val{'opt_string'}>\n|;
  657.  
  658.     print "<center><table cellpadding=5 width=450>";
  659.  
  660.     print "<tr><th align=left>Filesystem:</th><th align=left>$name</th></tr>";
  661.  
  662.     print "<tr><th align=left>Mount directory:</th><th align=left>",
  663.         &text('dir', $val{'dir'}, 20),
  664.         "</th></tr>\n";
  665.  
  666.     print "<tr><th align=left>Filesystem type:</th><th align=left>",
  667.         &select('type', $val{'type'}, 'xfs', 'efs', 'nfs', 'proc', 'fd',
  668.                 'cdfs', 'iso9660', 'cdda', 'dos', 'hfs', 'swap',
  669.                 'cachefs', 'rawdata'),
  670.         "</th></tr>\n";
  671.  
  672.     print "<tr><th align=left>Set Advanced Options:</th><th align=left>",
  673.         "<input type=submit name=\"options\" value=\"Options\" ",
  674.         "onClick=\"markOther()\"></th></tr>\n";
  675.  
  676.     print "</table></center><br>";
  677.  
  678.     print &js_buttons('ok','Ok','onClick="markOK()"','onClick="markOther()"',
  679.         "onClick=\"do_help('$help_page'); return (false)\"");
  680.  
  681.     print "</form></body></html>";
  682. }
  683.     
  684. sub getAccounts {
  685.     undef (@dir); 
  686.     undef (@accounts);
  687.     undef (@type);
  688.     undef (@opt_string);
  689.  
  690.     open(IN, "< $conf");
  691.     while (<IN>) {
  692.         next if $_ eq "\n";
  693.         next if $_ =~ /^\s+#/;
  694.         @items = split(/\s+/);
  695.         push(@accounts, $items[0]);
  696.         push(@dir, $items[1]);
  697.         push(@type, $items[2]);
  698.         push(@opt_string, $items[3]);
  699.     }
  700.     close(IN);
  701. }
  702.  
  703. sub generic {
  704.     &js_title_block($title,$js_main);
  705.     &header_block($title);
  706.  
  707.     print "<i>$message</i>";
  708.  
  709.     print "<form name=AccountForm action=$myname method=post "
  710.         . "onSubmit=\"return runSubmit()\">";
  711.  
  712.     if ($delete) {
  713.         print "<input type=hidden name=\"delFile\" value=$name>\n";
  714.     }
  715.  
  716.     print "<table width=400><center>\n";
  717.         print "<tr><td><input type=submit name=\"add\" onClick=\"markAdd()\" \n"
  718.                 . "value=\"Add New $account_type_uc\"\n"
  719.                 . "</td><td><input name=\"new_account\" value=\"$val{'new_account'}\"\n"
  720.                 . "size=19 onClick=\"markAdd()\"></td></tr>\n";
  721.  
  722.         if ($#accounts >= 0) {
  723.                 if ($_[0]) {
  724.                         undef @show_accts;
  725.                         foreach $arg (@accounts) {
  726.                                 push(@show_accts, $arg) if $arg ne $_[0];
  727.                         }
  728.                         print "<input type=hidden name=deleted value=$_[0]>\n";
  729.                 } else { @show_accts = @accounts; }
  730.  
  731.                 print "<tr><td>\n"
  732.                         . "<input type=submit name=\"edit\" onClick=\"markEdit()\" \n"
  733.                         . "value=\"Edit Selected $account_type_uc\"></td><td rowspan=2>";
  734.                 print &choice_list(*show_accts, "chosen", 20);
  735.                 print "</td/tr>\n"
  736.                         . "<tr><td><input type=submit name=\"delete\" onClick=\"markDelete()\" \n"
  737.                         . "value=\"Delete Selected $account_type_uc\"></td></tr>\n";
  738.         }
  739.  
  740.         print "</table></center><br>";
  741.  
  742.     print &js_buttons('doit','Ok','onClick="markOther()"',
  743.         'onClick="markOther()"',
  744.         "onClick=\"do_help('$help_page'); return (false)\"");
  745.  
  746.     print "</form></body></html>";
  747. }
  748.  
  749.